# -*- coding: utf-8 -*-

'''
author:Cooper
date:2012.5.7

旺旺API
see:http://open.taobao.com/doc/api_cat_detail.htm?cat_id=18&category_id=221

taobao.wangwang.eservice.avgwaittime.get 平均等待时长
taobao.wangwang.eservice.chatlog.get 获取具体的聊天记录
taobao.wangwang.eservice.chatpeers.get 获取聊天对象列表，查询时间段<=7天,只支持xml
taobao.wangwang.eservice.chatrecord.get 聊天记录查询
taobao.wangwang.eservice.evals.get 获取评价详细
taobao.wangwang.eservice.evaluation.get 客服评价统计
taobao.wangwang.eservice.groupmember.get 获取组成员列表
taobao.wangwang.eservice.loginlogs.get 获取登录日志
taobao.wangwang.eservice.noreplynum.get 客服未回复人数
taobao.wangwang.eservice.onlinetime.get 日累计在线时长
taobao.wangwang.eservice.receivenum.get 客服接待数
taobao.wangwang.eservice.streamweigths.get 获取分流权重接口
'''


from TopAPI.lib import *
import json

class avg_wait_time():
	api='taobao.wangwang.eservice.avgwaittime.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class chat_log():
	api='taobao.wangwang.eservice.chatlog.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,from_id,to_id,start_date,end_date,session='',format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class chat_peers():
	api='taobao.wangwang.eservice.chatpeers.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,chat_id,start_date,end_date,charset='utf-8',session='',format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class chat_record():
	api='taobao.wangwang.eservice.chatrecord.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,service_staff_id,start_date,end_date,session,format='xml'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		#j=json.loads(j.content,j.encoding)
		#TODO BeautifulStoneSoup
		return j
	pass
class evals():
	api='taobao.wangwang.eservice.evals.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class avg_wait_time():
	api='taobao.wangwang.eservice.evaluation.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class group_member():
	api='taobao.wangwang.eservice.groupmember.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,manager_id,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class lgin_logs():
	api='taobao.wangwang.eservice.loginlogs.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class noreplynum():
	api='taobao.wangwang.eservice.noreplynum.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class onlinetime():
	api='taobao.wangwang.eservice.onlinetime.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class receivenum():
	api='taobao.wangwang.eservice.receivenum.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,service_staff_id,start_date,end_date,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass
class onlinetime():
	api='taobao.wangwang.eservice.streamweigths.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,session,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(j.content,j.encoding)
		return j
	pass

def main():
	pass
if __name__=='__main__':
	main()
	pass
